package com.sun.lotter.luck;

import java.util.ArrayList;
import java.util.Date;
import java.util.Random;

import android.view.LayoutInflater;
import android.view.View;

import com.sun.base.BasePlayType;
import com.sun.bata.LotterData;
import com.sun.bata.MakeLotterNumber;
import com.sun.lotter.LotterNumberDialog;
import com.sun.lotter.R;

public class LuckPlayPage2 extends BasePlayType implements android.view.View.OnClickListener{

	public LuckPlayPage2(LuckLotterActivity context) {
		super(context);
		LayoutInflater.from(context).inflate(R.layout.luck_layout_2, this);
		findViewById(R.id.TextView_xz_01).setOnClickListener(this);
		findViewById(R.id.TextView_xz_02).setOnClickListener(this);
		findViewById(R.id.TextView_xz_03).setOnClickListener(this);
		findViewById(R.id.TextView_xz_04).setOnClickListener(this);
		findViewById(R.id.TextView_xz_05).setOnClickListener(this);
		findViewById(R.id.TextView_xz_06).setOnClickListener(this);
		findViewById(R.id.TextView_xz_07).setOnClickListener(this);
		findViewById(R.id.TextView_xz_08).setOnClickListener(this);
		findViewById(R.id.TextView_xz_09).setOnClickListener(this);
		findViewById(R.id.TextView_xz_10).setOnClickListener(this);
		findViewById(R.id.TextView_xz_11).setOnClickListener(this);
		findViewById(R.id.TextView_xz_12).setOnClickListener(this);
	}

	@Override
	public void onEvent(String e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onClick(View v) {
		int index = 0;
		switch (v.getId()) {
		case R.id.TextView_xz_01:
			index = 1;
			break;
		case R.id.TextView_xz_02:
			index = 2;
			break;
		case R.id.TextView_xz_03:
			index = 3;
			break;
		case R.id.TextView_xz_04:
			index = 4;
			break;
		case R.id.TextView_xz_05:
			index = 5;
			break;
		case R.id.TextView_xz_06:
			index = 6;
			break;
		case R.id.TextView_xz_07:
			index = 7;
			break;
		case R.id.TextView_xz_08:
			index = 8;
			break;
		case R.id.TextView_xz_09:
			index = 9;
			break;
		case R.id.TextView_xz_10:
			index = 10;
			break;
		case R.id.TextView_xz_11:
			index = 11;
			break;
		case R.id.TextView_xz_12:
			index = 12;
			break;
		}
		MakeLotterNumber makeLotterNumber = new MakeLotterNumber();
		Random rand = makeLotterNumber.getRandom(new Date(System.currentTimeMillis()), index, null, LotterData.DOUBLECOLORBALL, 0, 2);
		 ArrayList<String> list = makeLotterNumber.makeLotterNumbers(rand, LotterData.DOUBLECOLORBALL, 0, 1);
		new LotterNumberDialog(getContext(), list, LotterData.DOUBLECOLORBALL, 0).show();
	}

}
